﻿#!/usr/bin/env python3
# coding=utf-8
#

#


while True:
	user_password = open("user_password.txt","r+")
	userpasswd = user_password.read().split(",")
	login_user = input("PLS input user:")
	if login_user not in userpasswd:
		print("%s does not exist" %(login_user))
		choice = input("Do you want to regist it.(y/n)")
		if choice == "y":
			user_password.write(","+login_user)
			while True:
				password1=input("PLS input password:")
				password2=input("PLS input password agin:")
				if password1 != password2:
					print("pasword is bot equal.")
					continue
				else:
					user_password.write(","+password1)
					print("regist sucessful!")
					break
		else:
			continue
	else:
		for i in range(3):
			login_passwd = input("PLS input passowrd:")
			if login_passwd == userpasswd[userpasswd.index(login_user)+1]:
				print("Welcome! %s" %(login_user))
				break
		else:
			print("password is wrong!")
			continue
	user_password.close()
